home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 6
/
006.d81
/
pps #12
< prev
next >
Wrap
Text File
|
2022-08-26
|
2KB
|
132 lines
PEEKs, POKEs, and SYSes -- Part 12
by Jimmy Weiler
(continued from Part 11)
You MUST move both MEMSIZ and FRETOP
at the same time. Otherwise you will
leave some variables in your reserved
area and they will be destroyed when
you use that area for something else.
Now... Here's how.
To move top of BASIC down:
10 AD=24576:rem address declaration
20 AH%=AD/256:AL%=256*(AD/256-AH%)
25 rem low and high bytes of address
30 POKE51,AL%:POKE52,AH%
35 rem move FRETOP
40 POKE55,AL%:POKE56,AH%
45 rem move MEMSIZ
50 CLR
55 rem you need to clear out all vari-
ables because you just trashed them.
You can use this routine to move the
top of BASIC anywhere. Just change
the address in line 10.
MEMSIZ stays constant as a program
runs. FRETOP moves down as each
string variable is used. Eventually,
enough strings may be used to cause
FRETOP to move all the way down to
the bottom of free variable space.
When FRETOP collides with the bottom
of variable space, BASIC automatically
tries to move it back up to the top to
make room for more new strings. This
process is called garbage collection.
Essentially, garbage collection
works by squeezing all the strings
that have not been re-assigned into
a tight mass at the top of variable
space. Any old, obsolete, unused
string values are dropped into the bit
bucket.
If you have large string arrays,
garbage collection can take several
seconds to finish. During that time,
your Commodore will act as though the
keyboard has locked up.
If you have reduced the size of
BASIC memory, garbage collection will
be needed more often.
Finally, to get a feel for just how
MEMSIZ and FRETOP work together, try
this program:
10 FOR C = 1 to 128:B$=B$+"X":NEXT
20 MEMSIZ = PEEK(55)+PEEK(56)*256
30 FRTP = PEEK(51)+PEEK(52)*256
40 PRINT "<clr>"
50 PRINT "Top of memory = "MEMSIZ
60 PRINT "Bottom of strings = "FRTP
70 FOR C = 1 to 8:A$=B$:NEXT
80 GOTO 20
You should see that MEMSIZ sits firmly
in place while FRETOP falls and rises
as variables are assigned and garbage
collection happens.
----------- End of Article -----------